//
//  HRHearRecommendTopView.m
//  Hear
//
//  Created by mac on 2018/4/20.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "HRHearRecommendTopView.h"

@implementation HRHearRecommendTopView

-(instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame])
    {
        UIView *backgroundView = [[UIView alloc] init];
        backgroundView.layer.cornerRadius = 10;
        backgroundView.layer.masksToBounds = YES;
        backgroundView.backgroundColor = CustomColor(89, 99, 119, 1);
        [self addSubview:backgroundView];
        [backgroundView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top);
            make.left.mas_equalTo(self.mas_left);
            make.right.mas_equalTo(self.mas_right);
            make.height.mas_equalTo(100 * scaleHeight);
        }];
        
        _topicLabel = [[UILabel alloc] init];
        _topicLabel.font = [UIFont systemFontOfSize:15*scaleWidth];
        _topicLabel.textAlignment = NSTextAlignmentLeft;
        _topicLabel.textColor = UIColorFromRGB(0xFFFFFF);
        _topicLabel.numberOfLines = 0;
        UITapGestureRecognizer *tapLabel = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(entryTopicInfo)];
        tapLabel.numberOfTapsRequired = 1;       // 点击几次触发效果
        tapLabel.numberOfTouchesRequired = 1;    // 需要几个手指点击
        [_topicLabel addGestureRecognizer:tapLabel];
        [self addSubview:_topicLabel];
        [_topicLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.mas_top).offset(19 * scaleHeight);
            make.left.mas_equalTo(self.mas_left).offset(18 * scaleWidth);
            make.right.mas_equalTo(self.mas_right).offset(-18 * scaleWidth);
            //            make.bottom.mas_equalTo(backgroundView.bottom).offset(-42 * scaleHeight);
        }];
        
        _shareTopicBtn = [UIButton buttonWithType:0];
        [_shareTopicBtn setImage:[UIImage imageNamed:@"话题转发"] forState:0];
        [_shareTopicBtn addTarget:self action:@selector(shareButtonClick) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_shareTopicBtn];
        [_shareTopicBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.mas_equalTo(self.mas_right).offset(-19 * scaleWidth);
            make.top.mas_equalTo(backgroundView.mas_bottom).offset(-13 * scaleHeight);
            make.height.mas_equalTo(17 * scaleHeight);
            make.width.mas_equalTo(17 * scaleWidth);
        }];
        
        _answerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [_answerBtn setBackgroundImage:[UIImage imageNamed:@"答"] forState:UIControlStateNormal];
        [_answerBtn addTarget:self action:@selector(answerTopic) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:_answerBtn];
        [_answerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(backgroundView.mas_bottom).offset(-22.5 * scaleHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(45 * scaleWidth);
            make.height.mas_equalTo(45 * scaleWidth);
        }];
    }
    return self;
}

@end
